<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="/public/admin/js/html5.js"></script>
<script type="text/javascript" src="/public/admin/js/respond.min.js"></script>
<script type="text/javascript" src="/public/admin/js/PIE_IE678.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="/public/admin/css/H-ui.css"/>
<link type="text/css" rel="stylesheet" href="/public/admin/css/H-ui.admin.css"/>
<link type="text/css" rel="stylesheet" href="/public/admin/font/font-awesome.min.css"/>
<!--[if IE 7]>
<link href="/public/admin/font/font-awesome-ie7.min.css" rel="stylesheet" type="text/css" />
<![endif]-->
<title>集体广播</title>
</head>
<body>
<div class="pd-20">
  <div class="Huiform">
      <table class="table table-bg">
        <tbody>
         <tr>
            <td><textarea id='ct' rows="10" cols="80"></textarea> <p style="color:red">ps:发送本内容最好要超过5个文字 否则会造成文本排版问题！！！此发送内容为所以在线人员都能接受 请慎重！！。【本消息不做记录】</p></td>
          </tr>
          <tr>
            <td><button id='tijiao' class="btn btn-success radius" type="submit"><i class="icon-ok"></i> 确认广播</button></td>
          </tr>
        </tbody>
      </table>
  </div>
</div>

<script type="text/javascript" src="/public/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/public/admin/js/H-ui.js"></script> 
<script type="text/javascript" src="/public/admin/js/H-ui.admin.js"></script> 
<script type="text/javascript" src="/public/admin/js/self.js"></script> 
<script type="text/javascript" src="/public/admin/layer/layer.min.js"></script>
<script type="text/javascript">
window.onload=function(){
	var socket = new WebSocket('ws://<?php echo $GLOBALS['C']['IPDIR'];?>'); 
	socket.onopen = function(event) {
		  // 发送一个初始化消息

		var sendMessage={
				'code':1,
				'status':'say',
				'content':null,
				'from':0,
				'TO':0,
				'pic':'/public/gl.jpg',
				'nickname':'系统GM'
		};
		 var str=JSON.stringify(sendMessage);
		  socket.send(str); 
		  // 监听消息
		  	socket.onmessage = function(event) {
			  	
			}; 
			//监听Socket的关闭
			socket.onclose = function(event) { 
			 	alert('广播链接已经关闭 ，请重新打开！');
			}; 
	};

	var d=document.getElementById('tijiao');
	var ct=document.getElementById('ct');
	d.onclick=function(){
			var sendMessage={
				'code':6,
				'status':'say',
				'content':ct.value,
				'from':0,
				'TO':0,
				'pic':'/public/gl.jpg',
				'nickname':'系统GM'
			};
		 var str=JSON.stringify(sendMessage);
		 socket.send(str); 
		 ct.value='';
		 alert('广播发送成功。');
	}
	var e = event || window.event || arguments.callee.caller.arguments[0];
    if(e && e.keyCode==13){ // enter 键
        alert('a');
    	var d=document.getElementById('tijiao');
    	var ct=document.getElementById('ct');
    	var sendMessage={
				'code':6,
				'status':'say',
				'content':ct.value,
				'from':0,
				'TO':0,
				'pic':'/public/gl.jpg',
				'nickname':'系统GM'
			};
		 var str=JSON.stringify(sendMessage);
		 socket.send(str); 
		 ct.value='';
		 alert('广播发送成功。');
    }
}

</script>

</body>
</html>